package org.jeecg.modules.flow.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.HistoryService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.flow.query.HistoryActivityQuery;
import org.jeecg.modules.flow.service.IActHiActInstanceService;
import org.jeecg.modules.flow.service.IFlowDefService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "测试流程API")
@RestController
@RequestMapping("/flow/test")
@Slf4j
public class TestController {

    @Autowired
    public TaskService taskService;
    @Autowired
    public RuntimeService runtimeService;
    @Autowired
    public HistoryService historyService;
    @Autowired
    public RepositoryService repositoryService;

    @Autowired
    private IFlowDefService flowDefService;

    @Autowired
    private IActHiActInstanceService actHiActInstanceService;


    @GetMapping(value = "/test")
    @ApiOperation(value = "test", notes = "测试")
    public Result<?> rabbitMqClientTest(String processDefinitionId, String taskDefKey) {
        return Result.OK(flowDefService.prevTaskDefKey(processDefinitionId, taskDefKey));
    }

    @GetMapping(value = "/test1")
    @ApiOperation(value = "test1", notes = "测试1")
    public Result<?> rabbitMqClientTest1(HistoryActivityQuery query,
                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        return Result.OK(actHiActInstanceService.queryHistoricActivityInstance(query, pageNo, pageSize));
    }
}
